<!--获取文档修订记录-->
<template>
  <view>
    <van-popup v-model="showCompo" closeable round position="bottom" :style="{ height: '80%' }"
               @click-close-icon="toClose" @click-overlay="toClose">
      <van-row type="flex" justify="center">
        <van-col offset="3" span="8">
          <van-cell value="文档修订记录"/>
        </van-col>
      </van-row>
      <view class="padding-bottom">
        <van-cell icon="newspaper-o" title="文档修订记录" title-class="text-bold"/>
        <view class="">
          <van-row justify="center">
            <van-col span="5">
              <van-cell title="修订人" title-class="text-bold"></van-cell>
            </van-col>
            <van-col span="7">
              <van-cell title="修订人单位" title-class="text-bold"></van-cell>
            </van-col>
            <van-col span="6">
              <van-cell title="修订时间" title-class="text-bold"></van-cell>
            </van-col>
            <van-col span="6">
              <van-cell title="修订内容" title-class="text-bold"></van-cell>
            </van-col>
          </van-row>
          <van-row justify="center" v-for="(item,index) in revisionList" :key="index">
            <template>
              <van-col span="5">
                <van-cell :title="item.checkName"></van-cell>
              </van-col>
              <van-col span="7">
                <van-cell :title="item.deptName"></van-cell>
              </van-col>
              <van-col span="6">
                <van-cell class="" style="white-space: normal" :title="item.formatDate"></van-cell>
              </van-col>
              <van-col span="6">
                <van-cell title="查阅内容" title-class="text-blue" @click="getAttachmentByAttachId(item.operate)"></van-cell>
              </van-col>
            </template>
          </van-row>
        </view>
      </view>
    </van-popup>
  </view>
</template>

<script>

export default {
  props: {
    showRevision: {
      type: Boolean,
      default: false
    },
  },

  data() {
    return {
      showCompo: false,
      revisionList: [],    // 已传阅
      proInstId:'',
    };
  },

  watch: {
    showRevision(val) {
      this.showCompo = val
    },
  },

  mounted() {
  },

  methods: {
    // 获取文档修订记录
    getDocumentRecordByProInstId(proInstId) {
      this.proInstId = proInstId
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/maintext/getDocumentRecordByProInstId/` + this.proInstId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
          'page': 1,
          'rows': 100
        })
      }).then(({data}) => {
        //{"code":200,"data":{"total":3,"rows":[{"checkName":"范幸丽","deptName":"政务督查处（信访处）","agentName":"2022-03-17T11:43:47.279+0800","operate":"3e8be4a76435487eb85bdb2292edfec0","formatDate":"2022-03-17 11:43:47"}]},"message":null}
        if (data.code == 200) {
          this.revisionList = data.data.rows
        } else {
          this.$toast("文档记录获取失败：" + data.code)
        }
      })
    },
    getAttachmentByAttachId(attachId){
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/oabizattachment/getAttachmentByAttachId/` + attachId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
        })
      }).then(({data}) => {
        //{"code":200,"data":{"num":2},"message":null} 如果num>1 则显示文档修订记录按钮
        if (data.code == 200) {
          //调用蓝信打开文档
          this.lx.openFile(data.data,this.proInstId)
        } else {
          this.$toast("获取文件信息失败：" + data.code)
        }
      })
    },
    //关闭、取消按钮
    toClose() {
      this.$emit('closeRevisionSheet', this.showCompo)
    },

  },

}
</script>

<style scoped>
	/deep/ .van-cell {
		padding: 20rpx 20rpx;
	}

	/deep/ .van-grid-item__content {
	    display: -webkit-box;
	    display: -webkit-flex;
	    display: flex;
	    -webkit-box-orient: vertical;
	    -webkit-box-direction: normal;
	    -webkit-flex-direction: column;
	    flex-direction: column;
	    box-sizing: border-box;
	    height: 100%;
	    padding: 10px 8px;
	    background-color: #fff;
	}

  /deep/ .van-cell__title {
    min-width: 20% !important;
  }
</style>
